let github_mirror='https://ghproxy.com/https://github.com/'
call plug#begin()
" The default plugin directory will be as follows:
"   - Vim (Linux/macOS): '~/.vim/plugged'
"   - Vim (Windows): '~/vimfiles/plugged'
"   - Neovim (Linux/macOS/Windows): stdpath('data') . '/plugged'
" You can specify a custom plugin directory by passing it as the argument
"   - e.g. `call plug#begin('~/.vim/plugged')`
"   - Avoid using standard Vim directory names like 'plugin'

" Make sure you use single quotes
" 设置 Git 镜像
" let g:plug_github_mirror = 'https://hub.fastgit.xyz' 


" Shorthand notation; fetches https://github.com/junegunn/vim-easy-align
Plug github_mirror.'junegunn/vim-easy-align', { 'on': 'NERDTreeToggle' }

" Any valid git URL is allowed
Plug github_mirror.'junegunn/vim-github-dashboard.git', { 'on': 'NERDTreeToggle' }

" Multiple Plug commands can be written in a single line using | separators
" Plug 'SirVer/ultisnips' | Plug 'honza/vim-snippets'

" On-demand loading
Plug github_mirror.'preservim/nerdtree', { 'on': 'NERDTreeToggle' }

" Using a non-default branch
Plug github_mirror.'rdnetto/YCM-Generator', { 'branch': 'stable', 'on': 'NERDTreeToggle'}

" Plugin outside ~/.vim/plugged with post-update hook
" Plug github_mirror.'junegunn/fzf', { 'dir': '~/.fzf', 'do': './install --all' }

" 安装主题
Plug github_mirror.'nanotech/jellybeans.vim'

" 状态栏主题
Plug github_mirror.'vim-airline/vim-airline'
Plug github_mirror.'vim-airline/vim-airline-themes'

" jump cursor
Plug github_mirror.'easymotion/vim-easymotion', { 'on': 'NERDTreeToggle' }

" 快捷键提示
Plug github_mirror.'liuchengxu/vim-which-key', { 'on': ['WhichKey', 'WhichKey!'] }

" 平滑滚动
Plug github_mirror.'yuttie/comfortable-motion.vim', { 'on': 'NERDTreeToggle' }
" Plug 'myusuf3/numbers.vim'

" icon 显示
Plug github_mirror.'ryanoasis/vim-devicons', { 'on': 'NERDTreeToggle' }

Plug github_mirror.'t9md/vim-choosewin', { 'on': 'NERDTreeToggle' }

" 欢迎页
Plug github_mirror.'mhinz/vim-startify'
" Initialize plugin system
" - Automatically executes `filetype plugin indent on` and `syntax enable`.

Plug github_mirror.'tpope/vim-fugitive'

" 扩选文本范围
Plug github_mirror.'terryma/vim-expand-region'
map <c-w> <Plug>(expand_region_expand)
map <c-e> <Plug>(expand_region_shrink)

" 浮动终端
Plug github_mirror.'voldikss/vim-floaterm'

call plug#end()
" You can revert the settings after the call like so:
"   filetype indent off   " Disable file-type-specific indentation
"   syntax off            " Disable syntax highlighting


" 设置 <leader> 键
let mapleader = " "

set scrolloff=5

set number  			" 显示行号
set relativenumber		" 显示相对行号
set incsearch           " 实时开启搜索高亮
set hlsearch			" 搜索结果高亮
set autoindent			" 自动缩进
set smartindent			" 智能缩进
set tabstop=4			" 设置tab制表符号所占宽度为4
set softtabstop=4		" 设置按tab时缩进宽度为4
set shiftwidth=4		" 设置自动缩进宽度为4
set expandtab			" 缩进时将tab制表服转为空格
set smartcase           " 开启智能大小写查找
set encoding=utf-8      " Use UTF-8.
set showcmd             " Display incomplete commands.
set cursorline          " 高亮当前行
set ignorecase          " 设置忽略大小写
set smartcase           " 设置智能大小写
set ruler               " 设置显示当前位置

" 预览搜索结果
set incsearch

" 开启相对行数
set relativenumber

" 开启行高亮
set cursorline

" 设置可以让光标上下移动时，保持与上下边界10行的距离
set scrolloff=40

"自动语法高亮
syntax on

" 设置刷新快捷键
nnoremap <leader>r :source $MYVIMRC<CR>
" 使用 <leader> 键定义快捷键映射
nnoremap <leader>q :q<CR>

nnoremap <leader>t :NERDTreeToggle<CR>
nnoremap <C-f> :NERDTreeFind<CR>
nnoremap <leader>w :w<CR>


" 启用 Gruvbox 主题
syntax enable
colorscheme jellybeans
let g:airline_theme='deus'
let g:airline#extensions#tabline#formatter = 'jsformatter'  " 设置默认tab栏样式

" 自定义 EasyMotion 映射
" <Leader>f{char} to move to {char}
" map  <Leader>f <Plug>(easymotion-bd-f)
map f <Plug>(easymotion-overwin-f)
" s{char}{char} to move to {char}{char}
nmap F <Plug>(easymotion-overwin-f2)

" Move to line
map <leader>l <Plug>(easymotion-bd-jk)
" map <leader>l <Plug>(easymotion-overwin-line)

" invoke with '-'
nmap  -  <Plug>(choosewin)

" 快捷键帮助提示
nnoremap <leader>h :WhichKey '<Space>'<CR>

" 映射si 为垂直分割
map <C-h> :set splitright<CR>:vsplit<CR>
" 映射sn 为垂直分割
map <C-l> :set nosplitright<CR>:vsplit<CR>
" 映射si 为水平分割
map <C-k> :set nosplitbelow<CR>:split<CR>
" 映射si 为水平分割
map <C-j> :set splitbelow<CR>:split<CR>

"set clipboard=unnamedplus
" 将系统剪贴板内容粘贴到Vim中
" nnoremap p "+p
" vnoremap p "+p
 
" " 将Vim中的文本复制到系统剪贴板中
" nnoremap y "+y
" vnoremap y "+y

nnoremap <leader>s :FloatermToggle<CR>
" 分区不同状态，光标不同形状
if has("autocmd")
  au VimEnter,InsertLeave * silent execute '!echo -ne "\e[2 q"' | redraw!
  au InsertEnter,InsertChange *
    \ if v:insertmode == 'i' | 
    \   silent execute '!echo -ne "\e[6 q"' | redraw! |
    \ elseif v:insertmode == 'r' |
    \   silent execute '!echo -ne "\e[4 q"' | redraw! |
    \ endif
  au VimLeave * silent execute '!echo -ne "\e[ q"' | redraw!
endif

